package at.fhj.itm10.ticketmaster.services.res;

import java.io.File;

import javax.servlet.ServletContext;

import org.apache.log4j.Logger;

/**
 * "resource.xml" checker for people which do not get it to
 * read the README files.
 * 
 * @author Wolfgang Gaar
 */
public class ResourceXmlChecker {

	private Logger logger = Logger.getLogger("services");
	
	public ResourceXmlChecker(ServletContext servletContext) throws Exception {
		String path = servletContext.getRealPath("/") + "WEB-INF/resources.xml";
		
		boolean exists = new File(path).exists();

		logger.info("checking for resources.xml");
		logger.info("resources.xml: " + path);
		logger.info("resources.xml exists: " + exists);

		if (!exists) {
			throw new WhyYouNoReadTheReadmeException();
		}
	}

}
